<?php
echo $header;
echo $sidebar
?>		
<div class="span10 content">
    <?php echo $hugemenu ?>

    <h1><?php echo lang('slider_page_title'); ?></h1>
    <?php if ($message) { ?>
        <div class="alert alert-error">
            <a class="close" data-dismiss="alert" href="#">x</a><?php echo $message; ?>
        </div>
    <?php } if ($success) { ?>
        <div class="alert alert-success">
            <a class="close" data-dismiss="alert" href="#">x</a><?php echo $success; ?>
        </div>
    <?php } ?>

    <?php echo form_open_multipart(current_url()); ?>
    <div class="widget">
        <div class="widget-head"><h3 class="heading"><?php echo lang('slider_widget_title') ?></h3></div>
        <div class="widget-body">
            <div class="row-fluid">
                <div class="span12">	
                    <div class="control-group">
                        <label class="control-label photo">
                            <?php echo lang('slider_add_photo', 'photo'); ?>
                            <?php
                            echo form_upload('userfile', '', 'id="userfile"');
                            echo (isset($error)) ? $error : '';
                            ?>     
                        </label>
                        <div class="controls">
                            <link href="<?php echo base_url(); ?>assets/admin/js/jquery/uploadify_31/uploadify.css" type="text/css" media="screen" rel="stylesheet"/>
                            <script src="<?php echo base_url(); ?>assets/admin/js/jquery/uploadify_31/jquery.uploadify-3.1.min.js" type="text/javascript"></script>
                            <script type="text/javascript">
                                $(document).ready(function() {
                                    var base_url = '<?php echo base_url(); ?>';
                                    $('#userfile').uploadify({
                                        'auto': true,
                                        'swf': base_url + 'assets/admin/js/jquery/uploadify_31/uploadify.swf',
                                        'uploader': base_url + 'index.php/uploadify/do_upload',
                                        'cancelImg': base_url + 'uploadify-cancel.png',
                                        'fileTypeExts': '*.jpg;*.bmp;*.png;*.tif',
                                        'fileTypeDesc': 'Image Files (.jpg,.bmp,.png,.tif)',
                                        'fileSizeLimit': '5MB',
                                        'fileObjName': 'userfile',
                                        'buttonText': '<?php echo lang('estate_add_photo_btn') ?>',
                                        'multi': true,
                                        'removeCompleted': true,
                                        'onUploadSuccess': function(file, data, response) {
                                            obj = JSON.parse(data);
                                            $('.thumb').append('<div class="' + obj.file_name + '"><a class="deletelink" data-cc="slider" target="_blank" href="' + base_url + 'index.php/uploadify/delete_file/' + obj.file_name + '"><img src="' + base_url + 'uploads/' + obj.file_name + '" /></a><textarea name="title[]" class="span10"></textarea></div>');
                                            $('.photos').append('<input type="hidden" name="photo[]" value="' + obj.file_name + '" />');
                                        }
                                    });

                                });
                            </script>	
                        </div>
                    </div>

                    <div class="control-group">
                        <div class="thumb well well-small">
                            <?php
                                if ($photoData) {
                                    $baseUrl = base_url();
                                    foreach($photoData as $photo => $text){
                                        $filePath = $baseUrl . "uploads/" . $photo;
                                        if(!@getimagesize($filePath)){
                                            continue;
                                        }
                                        echo "<div class='$photo'><a class='deletelink' data-cc='slider' target='_blank' href='$baseUrl/index.php/uploadify/delete_file/$photo'><img src='$baseUrl/uploads/thumbs/$photo' /></a><textarea name='title[]' class='span10'>$text</textarea></div>";
                                    }
                                }
                            ?>
                            </div>
                        </div>
                        <div class="control-group">
                            <div class="photos">
                            <?php
                                if ($photoData) {
                                    $baseUrl = base_url();
                                    foreach($photoData as $photo => $text){
                                        $filePath = $baseUrl . "uploads/" . $photo;
                                        if(!@getimagesize($filePath)){
                                            continue;
                                        }
                                        echo "<input type='hidden' value='$photo' name='photo[]'>";
                                    }
                                }
                            ?>
                            </div>
                        </div>

                        <div class="control-group">
                            <label class="control-label"></label>
                            <div class="controls">
                                <?php echo form_submit('submit', lang('slider_btn'), 'class="btn btn-success span2"'); ?>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>

        <?php echo form_close(); ?>	


    </div>
    <!--/content-->

    <?php echo $footer ?>